/*
 * AbstractCollection.cpp
 *
 *  Created on: 2012-5-17
 *      Author: esf
 */
#include "../../java.lang/headfiles/Object.h"
#include "../headfiles/AbstractCollection.h"

namespace collection {
template <class T>
	bool collection::AbstractCollection<T>::isEmpty()
	{
		return this->size()==0;
	}
template <class T>
	bool collection::AbstractCollection<T>::contains(Object& o)
	{
		Iterator<T> it=this->iterator();

		if(o==null)
		{
			while(it.hasNext())
			{
				if((Object)it.next()==null)
					return true;
			}
		}
		else
		{
			while(it.hasNext())
			{
				if(o.equals(it.next()))
					return true;
			}
		}

		return false;
	}
	template <class E>
	Object* collection::AbstractCollection<E>::toArray()
	{
		/*not finished*/
		return NULL;
	}
	template <class E>
	bool collection::AbstractCollection<E>::add(E& e)
	{
		throw "UnSupportException";
		return false;
	}
} /* namespace collection */
